<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs For Class Psa_User</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">			
<h2 class="class-name"><img src="../media/images/Class_logo.png"
														alt=" Class"
														title=" Class"
														style="vertical-align: middle"> Psa_User</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
													<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
						|											<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
						
					</div>
	<div class="info-box-body">
        		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">User object class.</p>
<p class="description"><p>Here are some examples of using Psa_User object. You will mostly use Psa_User objects  in model methods. Here are parts of code that can be used in some model method:</p><p><strong>Examples</strong></p><p><strong>1)</strong> Create a new user:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;user&nbsp;object</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../psa/Psa_User.html">Psa_User</a></span><span class="src-sym">(</span><span class="src-str">'new'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;new&nbsp;user&nbsp;username</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../psa/Psa_User.html#var$username">username</a>&nbsp;</span>=&nbsp;<span class="src-str">'new_user'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;new&nbsp;user&nbsp;password</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../psa/Psa_User.html#var$password">password</a>&nbsp;</span>=&nbsp;<span class="src-str">'new_user_pass'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;save&nbsp;user&nbsp;to&nbsp;database</span></div></li>
<li><div class="src-line">&nbsp;try<span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodsave">save</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<span class="src-str">&quot;new&nbsp;user&nbsp;is&nbsp;created&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;catch<span class="src-sym">(</span><span class="src-id"><a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a>&nbsp;</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<span class="src-str">&quot;error.&nbsp;user&nbsp;not&nbsp;created.&nbsp;Maybe&nbsp;already&nbsp;exists.&nbsp;See&nbsp;log&nbsp;for&nbsp;details.&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
</ol></div></p><p><strong>2)</strong> Authorize user by username &amp; password and save some properties of the user:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;user&nbsp;object</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../psa/Psa_User.html">Psa_User</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;set&nbsp;username&nbsp;&amp;&nbsp;password</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../psa/Psa_User.html#var$username">username</a>&nbsp;</span>=&nbsp;<span class="src-str">'john'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../psa/Psa_User.html#var$password">password</a>&nbsp;</span>=&nbsp;<span class="src-str">'fish'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;if&nbsp;user&nbsp;is&nbsp;authorized&nbsp;save&nbsp;some&nbsp;custom&nbsp;properties</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodauthorize">authorize</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id">likes_to_eat&nbsp;</span>=&nbsp;<span class="src-str">'potato'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id">likes_to_drink&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'cola'</span><span class="src-sym">,</span><span class="src-str">'bear'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodsave">save</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
</ol></div></p><p><strong>3)</strong> Extend <kbd>Psa_User</kbd> class and add new authorization method:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;My_Psa_User&nbsp;class</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">class&nbsp;</span><span class="src-id">My_Psa_User&nbsp;</span><span class="src-key">extends&nbsp;</span><a href="../psa/Psa_User.html">Psa_User</a><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">ldap_authorization</span><span class="src-sym">(</span><span class="src-var">$ldap_username</span><span class="src-sym">,</span><span class="src-var">$ldap_password</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;LDAP&nbsp;authorization&nbsp;and&nbsp;set&nbsp;$ok_in_ldap&nbsp;flag</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;...</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;if&nbsp;LDAP&nbsp;authorization&nbsp;passed</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$ok_in_ldap</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">username&nbsp;</span>=&nbsp;<span class="src-var">$ldap_username</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">authorize</span><span class="src-sym">(</span><span class="src-str">'username'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
</ol></div></p><p>Code in some model method:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;user&nbsp;object</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id">My_Psa_User</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;authorize&nbsp;user.&nbsp;Users&nbsp;in&nbsp;the&nbsp;psa_user&nbsp;database&nbsp;table&nbsp;should&nbsp;have&nbsp;the&nbsp;same&nbsp;usernames&nbsp;like&nbsp;in&nbsp;ldap</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id">ldap_authorization</span><span class="src-sym">(</span><span class="src-str">'My_ldap_username'</span><span class="src-sym">,</span><span class="src-str">'My_ldap_pass'</span><span class="src-sym">))</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;save&nbsp;last&nbsp;login&nbsp;time</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodsave_last_login_time">save_last_login_time</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
</ol></div></p><p><strong>4)</strong> Change user's group membership and check some tags:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;user&nbsp;object</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../psa/Psa_User.html">Psa_User</a></span><span class="src-sym">(</span><span class="src-num">10</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;authorize&nbsp;user&nbsp;by&nbsp;id</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodauthorize">authorize</a><span class="src-sym">(</span><span class="src-str">'id'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;remove&nbsp;user&nbsp;from&nbsp;all&nbsp;user&nbsp;groups</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodremove_group">remove_group</a><span class="src-sym">(</span><span class="src-str">'all'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;remove&nbsp;the&nbsp;user&nbsp;from&nbsp;group&nbsp;with&nbsp;ID&nbsp;9&nbsp;and&nbsp;put&nbsp;it&nbsp;in&nbsp;groups:&nbsp;3,5&nbsp;and&nbsp;7</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodremove_group">remove_group</a><span class="src-sym">(</span><span class="src-num">9</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodadd_group">add_group</a><span class="src-sym">(</span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">3</span><span class="src-sym">,</span><span class="src-num">5</span><span class="src-sym">,</span><span class="src-num">7</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;check&nbsp;if&nbsp;user&nbsp;has&nbsp;tag&nbsp;'picture_upload'</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodhas_tag">has_tag</a><span class="src-sym">(</span><span class="src-str">'picture_upload'</span><span class="src-sym">))</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;do&nbsp;something</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
</ol></div></p><p><strong>Note:</strong> Read more about the tags <a href="../psa/tutorial_psa_features.pkg.html#usersgroups.tags">here</a>.</p></p>
		<p class="notes">
			Located in <a class="field" href="_scripts---Psa_User.class.php.html">/scripts/Psa_User.class.php</a> (line <span class="field"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a131">131</a></span>)
		</p>
		
				
		<pre></pre>
	
			</div>
</div>



	<a name="sec-var-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Variable Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
						<span class="disabled">Vars</span> (<a href="#sec-vars">details</a>)
							| 
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
							
								</div>
		<div class="info-box-body">
			<div class="var-summary">
																																																																								<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">int</span>
					<a href="#$authorized" title="details" class="var-name">$authorized</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">array</span>
					<a href="#$groups" title="details" class="var-name">$groups</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">int</span>
					<a href="#$id" title="details" class="var-name">$id</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">int</span>
					<a href="#$last_login" title="details" class="var-name">$last_login</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">string</span>
					<a href="#$password" title="details" class="var-name">$password</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">array</span>
					<a href="#$tags" title="details" class="var-name">$tags</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">string</span>
					<a href="#$username" title="details" class="var-name">$username</a>
				</div>
											</div>
		</div>
	</div>

	<a name="sec-method-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Method Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
																		<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
				 
				|
						<span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
		</div>
		<div class="info-box-body">			
			<div class="method-summary">
																																																																																																																																<div class="method-definition">
					<img src="../media/images/Constructor.png" alt=" "/>
											<span class="method-result">Psa_User</span>
										<a href="#__construct" title="details" class="method-name">__construct</a>
											([<span class="var-type">int|string</span>&nbsp;<span class="var-name">$user_id</span> = <span class="var-default">null</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#add_group" title="details" class="method-name">add_group</a>
											(<span class="var-type">int|array</span>&nbsp;<span class="var-name">$group_id</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#authorize" title="details" class="method-name">authorize</a>
											([<span class="var-type">string</span>&nbsp;<span class="var-name">$type</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$run_plugins</span> = <span class="var-default">true</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#has_tag" title="details" class="method-name">has_tag</a>
											(<span class="var-type">int|string</span>&nbsp;<span class="var-name">$tag_id</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#password_change" title="details" class="method-name">password_change</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$new_password</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">string</span>
										<a href="#password_encrypt" title="details" class="method-name">password_encrypt</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$password</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#password_verify" title="details" class="method-name">password_verify</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$password</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#remove_group" title="details" class="method-name">remove_group</a>
											(<span class="var-type">int|array|string</span>&nbsp;<span class="var-name">$group_id</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#save" title="details" class="method-name">save</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#save_last_login_time" title="details" class="method-name">save_last_login_time</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#session_restore" title="details" class="method-name">session_restore</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int|string</span>
										<a href="#session_save" title="details" class="method-name">session_save</a>
											([<span class="var-type">bool</span>&nbsp;<span class="var-name">$only_return</span> = <span class="var-default">null</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#set_groups" title="details" class="method-name">set_groups</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int</span>
										<a href="#set_tags" title="details" class="method-name">set_tags</a>
										()
									</div>
											</div>
		</div>
	</div>		

	<a name="sec-vars"></a>
	<div class="info-box">
		<div class="info-box-title">Variables</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
										<a href="#sec-var-summary">Vars</a> (<span class="disabled">details</span>)
						
			
										| 
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
							
					</div>
		<div class="info-box-body">
			
<a name="var$authorized" id="$authorized"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">int</span>
			<span class="var-name">$authorized</span>
			 = <span class="var-default"> 0</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a253">253</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Flag if user is authorized.</p>
<p class="description"><p>If <a href="../psa/Psa_User.html#methodauthorize">authorize()</a> method returns true it is set to 1.</p><p><strong>Note:</strong> You have read access to this property.</p></p>
	<ul class="tags">
				<li><span class="field">access:</span> protected</li>
			</ul>
	
	
		
		

</div>
<a name="var$groups" id="$groups"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$groups</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a211">211</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Array with all groups user is in.</p>
<p class="description"><p>This array is set with <a href="../psa/Psa_User.html#methodset_tags">set_tags()</a> method.</p><p>Example:<pre> Array
 (
     [11] => 'admins'  // array index is group id and value is group name
     [14] => 'users'
     [33] => 'other'
 )</pre></p><p><strong>Note:</strong> You have read access to this property.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodset_tags">Psa_User::set_tags()</a></li>
				<li><span class="field">access:</span> protected</li>
			</ul>
	
	
		
		

</div>
<a name="var$id" id="$id"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">int</span>
			<span class="var-name">$id</span>
						(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a140">140</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">User ID.</p>
<p class="description"><p>Primary key from <kbd>psa_user</kbd> database table.</p><p><strong>Note:</strong> You can set this property only if not set, otherwise you have only read access to this property.</p></p>
	<ul class="tags">
				<li><span class="field">access:</span> protected</li>
			</ul>
	
	
		
		

</div>
<a name="var$last_login" id="$last_login"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">int</span>
			<span class="var-name">$last_login</span>
			 = <span class="var-default"> 0</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a223">223</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">UNIX timestamp of time user has last logged in.</p>
<p class="description"><p>Last login time has to be saved with <a href="../psa/Psa_User.html#methodsave_last_login_time">save_last_login_time()</a> method.</p><p><strong>Note:</strong> You have read access to this property.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodsave_last_login_time">Psa_User::save_last_login_time()</a></li>
				<li><span class="field">access:</span> protected</li>
			</ul>
	
	
		
		

</div>
<a name="var$password" id="$password"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">string</span>
			<span class="var-name">$password</span>
						(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a160">160</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Password (not encrypted).</p>
<p class="description"><p>You will need to set this property when you authorize user with username and password or when you  creating a new user. This property will not be set after authorization with <a href="../psa/Psa_User.html#methodauthorize">authorize()</a> method.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodpassword_change">Psa_User::password_change()</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodpassword_encrypt">Psa_User::password_encrypt()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$tags" id="$tags"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$tags</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a190">190</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Array with user tags.</p>
<p class="description"><p>Always check user's tags with <a href="../psa/Psa_User.html#methodhas_tag">has_tag()</a> method because it will refresh this array if  user's group membership has changed.  This array is set with <a href="../psa/Psa_User.html#methodset_tags">set_tags()</a> method.  Array structure is same as <a href="../psa/Psa_Group.html#var$tags">$tags</a>  array in <a href="../psa/Psa_Group.html">Psa_Group</a> object. The difference is that this one contains enabled tag from  all groups user is in. Indexes in this array are tags (tag names) that are set for the user.  All elements will have value 1.  Read more about the tags <a href="../psa/tutorial_psa_features.pkg.html#usersgroups.tags">here</a>.</p><p>Example:<pre> Array
 (
     ['address_book'] => 1
     ['download_file'] => 1
     ['view_source'] => 1
 )</pre></p><p><strong>Note:</strong> You have read access to this property.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Group.html#var$tags">Psa_Group::$tags</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodhas_tag">Psa_User::has_tag()</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodset_tags">Psa_User::set_tags()</a></li>
				<li><span class="field">access:</span> protected</li>
			</ul>
	
	
		
		

</div>
<a name="var$username" id="$username"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">string</span>
			<span class="var-name">$username</span>
						(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a148">148</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Username</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
						
		</div>
	</div>
	
	<a name="sec-methods"></a>
	<div class="info-box">
		<div class="info-box-title">Methods</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
															<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
														<a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
						
		</div>
		<div class="info-box-body">
			<A NAME='method_detail'></A>
<a name="method__construct" id="__construct"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Constructor.png" />
		<span class="method-title">Constructor __construct</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a307">307</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Constructor method.</p>
<p class="description"><p>Can be called with three types of arguments: <ul><li>If called with '<kbd>new</kbd>' as the argument new user will be created when <a href="../psa/Psa_User.html#methodsave">save()</a>
   method is called.</li><li>If called with user ID as argument, objects property <a href="../psa/Psa_User.html#var$id">$id</a> is set. In this case
   <var>$user_id</var> must be an integer value so be sure to pass integer as the argument
   and use cast operator <kbd>(int)</kbd>.</li><li>If <var>$user_id</var> parameter is string (different from '<kbd>new</kbd>'),
   the <a href="../psa/Psa_User.html#var$username">$username</a> property is set.</li></ul></p></p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">Psa_User</span>
		<span class="method-name">
			__construct
		</span>
					([<span class="var-type">int|string</span>&nbsp;<span class="var-name">$user_id</span> = <span class="var-default">null</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">int|string</span>
				<span class="var-name">$user_id</span><span class="var-description">: '<kbd>new</kbd>' if new user should be created or ID or username of the user</span>			</li>
				</ul>
		
			
	</div>
<a name="methodadd_group" id="add_group"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">add_group</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a633">633</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Puts user in a group or more groups if the <var>$group_id</var> argument is array.</p>
<p class="description"><p>Group membership changes are immediately stored in the database and you don't have to  call <a href="../psa/Psa_User.html#methodsave">save()</a> method after.  If you creating a new user this method must be called after <a href="../psa/Psa_User.html#methodsave">save()</a> method.  Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> on error.</p><p>Example:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;user&nbsp;object</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../psa/Psa_User.html">Psa_User</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;set&nbsp;user&nbsp;ID&nbsp;and&nbsp;authorize&nbsp;user</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../psa/Psa_User.html#var$id">id</a>&nbsp;</span>=&nbsp;<span class="src-num">123</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodauthorize">authorize</a><span class="src-sym">(</span><span class="src-str">'id'</span><span class="src-sym">))</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;put&nbsp;user&nbsp;in&nbsp;groups&nbsp;that&nbsp;have&nbsp;IDs&nbsp;4,12&nbsp;and&nbsp;33</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodadd_group">add_group</a><span class="src-sym">(</span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">4</span><span class="src-sym">,</span><span class="src-num">12</span><span class="src-sym">,</span><span class="src-num">33</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
</ol></div></p><p></p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1 for success, -1 user already was in the group (or more groups)  or group does not exists</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodremove_group">Psa_User::remove_group()</a></li>
				<li><span class="field">throws:</span> Psa_User_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			add_group
		</span>
					(<span class="var-type">int|array</span>&nbsp;<span class="var-name">$group_id</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">int|array</span>
				<span class="var-name">$group_id</span><span class="var-description">: id of the group. Or array with groups ids.</span>			</li>
				</ul>
		
			
	</div>
<a name="methodauthorize" id="authorize"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">authorize</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a355">355</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Authorizes the user.</p>
<p class="description"><p>Checks if user exists and loads data about the user from the database and restores object properties  previously saved with <a href="../psa/Psa_User.html#methodsave">save()</a> method.  See examples in <a href="../psa/Psa_User.html">Psa_User</a> class description.</p><p>There are three authorization types: <ul><li>If <var>$type</var> argument is '<kbd>id</kbd>' it sets the user data (if exists in database)
   without checking username and password. <a href="../psa/Psa_User.html#var$id">$id</a> object property must be set before for
   this authorization type.</li><li>If <var>$type</var> argument is '<kbd>username</kbd>' it authorizes the user (if exists in database) and sets user data
   without checking username and password. <a href="../psa/Psa_User.html#var$username">$username</a> object property must be set before
   for this authorization type.</li><li>If <var>$type</var> argument is not set <a href="../psa/Psa_User.html#var$username">$username</a> and <a href="../psa/Psa_User.html#var$password">$password</a> properties
   are required to be set.</li></ul>  <em>id</em> and <em>username</em> authorization types can be useful, for example, if you store only user  id in session or want to switch user in your application or usernames and passwords are stored  in external source like LDAP.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1 for success, 0 if not authorized</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			authorize
		</span>
					([<span class="var-type">string</span>&nbsp;<span class="var-name">$type</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$run_plugins</span> = <span class="var-default">true</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$type</span><span class="var-description">: '<kbd>id</kbd>' for authorization only by user ID, null (default)  for authorization with username and password, '<kbd>username</kbd>' for authorization only  by username</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$run_plugins</span><span class="var-description">: if false Psa_Plugin_After_User_Authorize plugins will not be invoked</span>			</li>
				</ul>
		
			
	</div>
<a name="methodhas_tag" id="has_tag"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">has_tag</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a1091">1091</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Checks if user has the given tag.</p>
<p class="description"><p>It calls <a href="../psa/Psa_User.html#methodset_tags">set_tags()</a> method if tags are not set before.  It just checks if array element with index <var>$tag_id</var> exists in the <a href="../psa/Psa_User.html#var$tags">$tags</a> array.  Read more about the tags <a href="../psa/tutorial_psa_features.pkg.html#usersgroups.tags">here</a>.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1-user has tag, 0-user hasn't tag, -1 error checking for tag</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodset_tags">Psa_User::set_tags()</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#var$tags">Psa_User::$tags</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			has_tag
		</span>
					(<span class="var-type">int|string</span>&nbsp;<span class="var-name">$tag_id</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">int|string</span>
				<span class="var-name">$tag_id</span><span class="var-description">: tag id (name)</span>			</li>
				</ul>
		
			
	</div>
<a name="methodpassword_change" id="password_change"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">password_change</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a768">768</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Changes user password.</p>
<p class="description"><p>New password will be hashed with <a href="../psa/Psa_User.html#methodpassword_encrypt">password_encrypt()</a> method and stored in the database.  When creating a new user you don't have to call this method, just set $password property.  You need to call it only when you want to change password for existing user.  Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> on error.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1 for success</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodpassword_encrypt">Psa_User::password_encrypt()</a></li>
				<li><span class="field">throws:</span> Psa_User_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			password_change
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$new_password</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$new_password</span><span class="var-description">: new user password</span>			</li>
				</ul>
		
			
	</div>
<a name="methodpassword_encrypt" id="password_encrypt"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">password_encrypt</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a860">860</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Encrypts user password. Password encrypted with this method will be stored in the database.</p>
<p class="description"><p>It uses <kbd>hash()</kbd> PHP function. The hash type is set by <kbd>$PSA_CFG['password_hash']</kbd>  value in <kbd>config.php</kbd> file. By default is sha256.  Override this method by extending <a href="../psa/Psa_User.html">Psa_User</a> class if you want to change password hashing  function.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> hashed (encrypted) password</li>
				<li><span class="field">see:</span> <a href="../psa/_config.php.html">config.php</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodpassword_change">Psa_User::password_change()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">string</span>
		<span class="method-name">
			password_encrypt
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$password</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$password</span><span class="var-description">: password</span>			</li>
				</ul>
		
			
	</div>
<a name="methodpassword_verify" id="password_verify"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">password_verify</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a812">812</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Verifies user password.</p>
<p class="description"><p>Checks if given string is user's password. This method can be used in process of changing user password to  verify old password. Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> on error.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1 given password is valid, 0 given password is invalid</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodpassword_encrypt">Psa_User::password_encrypt()</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodpassword_change">Psa_User::password_change()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			password_verify
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$password</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$password</span><span class="var-description">: password</span>			</li>
				</ul>
		
			
	</div>
<a name="methodremove_group" id="remove_group"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">remove_group</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a667">667</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Remove user from a group or more groups if $group_id argument is array.</p>
<p class="description"><p>Group membership changes are immediately stored in the database and you don't have to  call <a href="../psa/Psa_User.html#methodsave">save()</a> method after.  If you creating a new user this method must be called after <a href="../psa/Psa_User.html#methodsave">save()</a> method.  Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> on error.  This method calls <a href="../psa/Psa_User.html#methodset_groups">set_groups()</a> method after group membership is changed</p><p>Example:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;user&nbsp;object</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../psa/Psa_User.html">Psa_User</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;set&nbsp;user&nbsp;ID&nbsp;and&nbsp;authorize&nbsp;user</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../psa/Psa_User.html#var$id">id</a>&nbsp;</span>=&nbsp;<span class="src-num">123</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodauthorize">authorize</a><span class="src-sym">(</span><span class="src-str">'id'</span><span class="src-sym">))</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;remove&nbsp;user&nbsp;from&nbsp;groups&nbsp;that&nbsp;have&nbsp;ID&nbsp;4</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user</span><span class="src-sym">-&gt;</span><a href="../psa/Psa_User.html#methodremove_group">remove_group</a><span class="src-sym">(</span><span class="src-num">4</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol></div></p><p></p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1 for success, -1 user was not in the group (or more groups)  or group does not exists</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodadd_group">Psa_User::add_group()</a></li>
				<li><span class="field">throws:</span> Psa_User_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			remove_group
		</span>
					(<span class="var-type">int|array|string</span>&nbsp;<span class="var-name">$group_id</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">int|array|string</span>
				<span class="var-name">$group_id</span><span class="var-description">: id of the group or array with group ids. '<kbd>all</kbd>'  for remove user from all groups.</span>			</li>
				</ul>
		
			
	</div>
<a name="methodsave" id="save"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">save</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a510">510</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Saves all custom properties of the user object to the database.</p>
<p class="description"><p>In your application you can add some custom properties to user object, or add some properties by  extending user class and save those values to the database with this method.  All saved properties will be restored when the <a href="../psa/Psa_User.html#methodauthorize">authorize()</a> method is called and is successful.  See <kbd>serialize()</kbd> PHP function for details what you can save.  See examples in <a href="../psa/Psa_User.html">Psa_User</a> class description. Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> on error.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1 for success</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodauthorize">Psa_User::authorize()</a></li>
				<li><span class="field">throws:</span> Psa_User_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			save
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodsave_last_login_time" id="save_last_login_time"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">save_last_login_time</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a1127">1127</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Sets last login time value for the user to current time.</p>
<p class="description"><p>You need to call this method when you want to set last login time for the user.  This method is not automatically called from the <a href="../psa/Psa_User.html#methodauthorize">authorize()</a> method because  every authorization doesn't mean that user has logged in. For example, you can authorize  some user just to check if exists.  Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> on error.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1-success</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#var$last_login">Psa_User::$last_login</a></li>
				<li><span class="field">throws:</span> Psa_User_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			save_last_login_time
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodsession_restore" id="session_restore"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">session_restore</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a942">942</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Restores objects properties from session previously saved with session_save() method.</p>
<p class="description"><p>PHP sessions have to be started with <kbd>session_start()</kbd> function before calling this method.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 0 if session value <kbd>$_SESSION['psa_user_serialized']</kbd> is not set or its value  is not Psa_User object. 1 for successful restore.</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodsession_save">Psa_User::session_save()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			session_restore
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodsession_save" id="session_save"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">session_save</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a908">908</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Stores user object into PHP session or returns serialized representation of the user object.</p>
<p class="description"><p>This is useful if you want to store complete user object and to restore it on next request without  need to query the database.  If you store object into session with this method, session variable that holds  serialized data will be updated on every call to <a href="../psa/Psa_User.html#methodsave">save()</a> method.  The name of session variable will be <kbd>psa_user_serialized</kbd>.  Also, in all log messages will contain <kbd>user_id</kbd> and <kbd>username</kbd> from this session  variable. See <a href="../psa/Psa_Logger.html#methodlog">Psa_Logger::log()</a> method for details.  Throws <a href="../psa/exceptions/Psa_User_Exception.html">Psa_User_Exception</a> if session is not started before calling this method.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodsession_restore">Psa_User::session_restore()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int|string</span>
		<span class="method-name">
			session_save
		</span>
					([<span class="var-type">bool</span>&nbsp;<span class="var-name">$only_return</span> = <span class="var-default">null</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$only_return</span><span class="var-description">: if true, only serialized string will be returned.</span>			</li>
				</ul>
		
			
	</div>
<a name="methodset_groups" id="set_groups"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">set_groups</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a1075">1075</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Sets $groups array with all groups user is in.</p>
<p class="description"><p>This is alias for <a href="../psa/Psa_User.html#methodset_tags">set_tags()</a> method</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodset_tags">Psa_User::set_tags()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			set_groups
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodset_tags" id="set_tags"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">set_tags</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_User.class.php.html#a1022">1022</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Fills $tags array with all tags for the user.</p>
<p class="description"><p>It collects all tags from all groups the user is in.</p><p>It also sets <a href="../psa/Psa_User.html#var$groups">$groups</a> array with all groups user is in.  This method is automatically called by <a href="../psa/Psa_User.html#methodhas_tag">has_tag()</a> method if user's tags  are not set or user's group membership has changed.</p><p>If some group tag has been changed (with <a href="../psa/Psa_Group.html#methodadd_tag">add_tag()</a> or  <a href="../psa/Psa_Group.html#methodremove_tag">remove_tag()</a> methods), and that change affects the user  (user is in that group), you have to call this method again if you want to update user's tags.</p><p>You shouldn't call this method on every web request (through <a href="../psa/Psa_User.html#methodhas_tag">has_tag()</a> method also)  if your users are in many groups. Instead you can use <a href="../psa/Psa_User.html#methodsession_save">session_save()</a> method to store  complete user object into session and to restore it on next request with <a href="../psa/Psa_User.html#methodsession_restore">session_restore()</a>  method.</p><p>Read more about the tags <a href="../psa/tutorial_psa_features.pkg.html#usersgroups.tags">here</a>.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1-tags are set</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#methodhas_tag">Psa_User::has_tag()</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_User.html#var$tags">Psa_User::$tags</a></li>
				<li><span class="field">throws:</span> Psa_User_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			set_tags
		</span>
				()
			</div>
	
		
			
	</div>
						
		</div>
	</div>

	
	<p class="notes" id="credit">
		Documentation generated on Thu, 21 Oct 2010 01:40:56 +0200 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
	</p>
	</div></body>
</html>